<template>
	<view>
		<view style="height: 100rpx;"></view>
		<view class="btn" @click="toIndex">
			<view class="icon" >
				<image class="icon_yuyue" src="../../static/icon_tianxie.png" mode="widthFix"></image>
			</view>
			<view class="text">
				<text>校内教职工填写</text>
			</view>
		</view>
		<view class="btn" @click="toInviteIndex">
			<view class="icon">
				<image class="icon_zhigong" src="../../static/icon_yaoqing.png" mode="widthFix"></image>
			</view>
			<view class="text">
				<text>邀请校外访客填写</text>
			</view>
		</view>
	</view>
</template>

<script>
	import multipleSelect from "@/components/multiple-select/multiple-select"
	import wPicker from "@/components/w-picker/w-picker.vue"
	import baseUrl from '../../api/api.js'
	import energy from './energy.png'
	import plateNumber from '@/components/plate-number/plateNumber.vue';
	import ClipboardJS from 'clipboard'


	let Base64 = require('js-base64').Base64
	export default {
		components: {
			plateNumber,
			wPicker,
			multipleSelect,
		},
		data() {
			return {
				
			}
		},
		onShow() {
			this.energy = energy;
		},
		onLoad() {	
			this.params = window.location.href.split('?')[1]
			if(this.getParam(location.href, "error")) {
				return uni.showModal({
					content: decodeURIComponent(Base64.decode(this.getParam(location.href, "error"))),
					showCancel: false,
					success: (res) => {
						if(res.confirm) {
							window.location.href = "https://passport.ustc.edu.cn/login";
						}
					}
				})
			}
			this.openId = this.getParam(location.href, "openId"); 
			if(!this.openId){
				window.location.href = "https://passport.ustc.edu.cn/login?service=http://bwclf.ustc.edu.cn/weixin/getOauthUrl";
			} 
		},
		methods: {
			toIndex() {
				uni.navigateTo({
					url: '/pages/employee/employee' + `?${this.params}`
				})
			},
			toInviteIndex() {
				uni.navigateTo({
					url: '/pages/invite/index' + `?${this.params}`
				})
			},
			getParam(path, name) {
				var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");
				if (reg.test(path))
					return decodeURIComponent(RegExp.$2.replace(/\+/g, " "));
				return "";
			}
		}
	}
</script>

<style lang="scss">
	.tip {
		margin: 30rpx;
		
		.title {
			font-size: 34rpx;
			margin-bottom: 10rpx;
		}
		.item {
			text-indent: 1rem;
			color: red;
		}
	}
	.btn {
		margin: 30rpx;
		background: #fff;
		border-radius: 20rpx;
		display: flex;
		align-items: center;
		padding: 30rpx;
		
		.icon {
			width: 160rpx;
			height: 160rpx;
			background: #2A82E4;
			border-radius: 50%;
			display: flex;
			align-items: center;
			justify-content: center;
		}
		.icon_yuyue {
			width: 100rpx;
			height: 100rpx;
		}
		.icon_zhigong {
			width: 100rpx;
			height: 100rpx;
		}
		.text {
			flex: 1;
			text-align: center;
			font-size: 38rpx;
			color: #333;
			text {
				display: inline-block;
			}
		}
	}	
</style>
